import 'package:flutter/material.dart';
import 'package:xim/common/get_style_view.dart';
import 'package:xim/common/style/colors.dart';
import 'package:xim/widget/common/state.dart';


class SessionCreatePageStyle extends Style with AppBarMixin {

  @override
  ModelColor bgColor = ModelColor(darkColor: const Color(0xff111111), lightColor: Colors.white);

  @override
  ModelColor textColor = ModelColor(lightColor: const Color((0xff161616)), darkColor: const Color(0xffcecece));

  ModelColor fgColor = ModelColor(lightColor: const Color(0xfffefefe), darkColor: const Color(0xff181818));

  @override
  ModelColor weakTextColor = ModelColor(lightColor: const Color(0xff737373), darkColor: const Color(0xff8c8c8c));

  @override
  Color get appBarBgColor => bgColor.color;

  @override
  String get appBarTitle => "发起群聊";

  @override
  TextStyle get appBarTitleStyle => TextStyle(color: textColor.color, fontSize: 14);

  @override
  IconThemeData get iconTheme => IconThemeData(color: textColor.color);

  @override
  List<ModelColor> get modelColors => [
    ...super.modelColors,
    bgColor,
    textColor,
    fgColor,
    weakTextColor,
  ];

  Widget searchBox({Function(String)? search}){
    var gap = 12.0;
    var textStyle = TextStyle(fontSize: 14, color: textColor.color);
    return Container(
      height: 38,
      margin: EdgeInsets.symmetric(horizontal: gap),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(8),
          border: Border.all(color: Colors.grey.shade500)
      ),
      child: TextField(
        style: textStyle,
        onSubmitted: (account){
          search?.call(account);
        },
        decoration: InputDecoration(
            hintText: "搜索",
            border: InputBorder.none,
            prefixIcon: Icon(Icons.search, color: weakTextColor.color,),
            hintStyle: TextStyle(fontSize: 14, color: weakTextColor.color)
        ),
      ),
    );
  }

  Widget titleItem({required String title}){
    return item(
        leftWidget: Text(
          title,
          style: TextStyle(fontSize: 14, color: textColor.color, fontWeight: FontWeight.w400),
        ),
        gap: 12
    );
  }

  Widget item({Widget? leftWidget,Widget? rightWidget, double gap=6.0, double verticalPadding=8}){
    return Container(
      padding: EdgeInsets.symmetric(vertical: verticalPadding),
      // color: Colors.red,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          if(leftWidget!=null) Row(
            children: [
              SizedBox(width: gap,),
              leftWidget,
            ],
          ),
          if(rightWidget!=null) Row(
            children: [
              rightWidget,
              SizedBox(width: gap,),
            ],
          ),
        ],
      ),
    );
  }
}